package ml.kupin.controller;

import ml.kupin.service.ItemCategoryService;
import ml.kupin.common.vo.EasyUITreeNode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 商品分类管理
 * Created by 小柯(Allen Kerr) on 17.4.25 9:36.
 */
@Controller
@RequestMapping("/item/cat")
public class ItemCategoryController {
    @Autowired
    private ItemCategoryService itemCategoryService;

    /**
     * 获取商品分类列表
     *
     * @return
     */
    @RequestMapping("/list")
    @ResponseBody
    public List<EasyUITreeNode> getCategories(@RequestParam(value = "id", defaultValue = "0") Long parentId) {
        //获取商品分类列表对应的EasyUITreeNode集合
        List<EasyUITreeNode> treeNodeList = itemCategoryService.getItemCategories(parentId);
        //返回
        return treeNodeList;
    }

}
